# 演示键盘组合键，鼠标的事件：右键，双击，左键。。。。
from selenium import webdriver
import time
# 引入键盘包
from selenium.webdriver.common.keys import Keys
# 引入可以点击鼠标的包
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
driver.get("https://www.baidu.com/")
driver.find_element_by_id("kw").send_keys("羊了个羊")
time.sleep(5)
# 演示鼠标的使用
b = driver.find_element_by_id("su")
# 双击
ActionChains(driver).double_click(b).perform()
time.sleep(2)

# 右键
ActionChains(driver).context_click(b).perform()
time.sleep(3)
# driver.find_element_by_id("su").click()

# 演示组合键的使用
# 全选输入框的内容
# driver.find_element_by_id("kw").send_keys(Keys.CONTROL, 'a')
# time.sleep(5)
# 剪切 相当于清除事件
# driver.find_element_by_id("kw").send_keys(Keys.CONTROL, 'x')
# time.sleep(5)
# 重新输入
# driver.find_element_by_id("kw").send_keys("gali")
# time.sleep(5)
# driver.find_element_by_id("su").click()
# time.sleep(5)

driver.quit()

